Choose (index, choice1, choice2, ..., choiceN)

Arguments
Returns

A value from the given list of choices. The type of the returned value is the same as the type of the choices.

Action

Choose returns a value from the list of choices based on the value of index. For example, if index is 1, it returns choice1 and if index is 2 it returns choice2 and so forth.

Typical uses
Examples

The following examples are applicable to both Basic and Crystal syntax:

Choose (3, "Poor", "Fair", "Good", "Excellent")

Returns the String "Good".

Choose (2, 10 To 20, 100 To 200, 60 To 70)

Returns the Number Range value 100 To 200.

If a company has fiscal year starting July 1 (the 3rd calendar quarter) and it wants to print the fiscal quarter of each order date:

Rem Basic syntax

formula = Choose (DatePart ("q", {Orders.Order Date}), _

                  "third fiscal quarter", "fourth fiscal quarter", _

                 " first fiscal quarter", "second fiscal quarter")


//Crystal syntax

Choose (DatePart ("q", {Orders.Order Date}),

         "third fiscal quarter", "fourth fiscal quarter",

         "first fiscal quarter", "second fiscal quarter")

If {Orders.Order Date} is February 18, 1996, then the DatePart function call returns 1 since this date is in the first calendar quarter. Thus, the first choice value, namely the String value "third fiscal quarter" is returned by the formula.

Comments
Related topics

IIF (expression, truePart, falsePart) function

Switch (expr1, value1, expr2, value2, ..., exprN, valueN) function

If-Then-Else operators

Select statements (Basic syntax)

Select expressions (Crystal syntax)



Seagate Software IMG Holdings, Inc.
http://www.seagatesoftware.com
Support services:
http://support.seagatesoftware.com